<?php 

class tasks extends CI_Controller {
/*
	function __construct() {
		parent::__construct();
		$this->is_logged_in();
	}

	function index(){
		$data = array();

		if ( $query = $this->tasks_model->get_tasks() ) {
			$data['tasks'] = $query;
		}
		$data['user_info'] =  $this->session->all_userdata();

		$data['main_content'] = 'tasks';
		$this->load->view('includes/template.php',$data);
	}

	function create(){
		$data = array(
			'title' => $this->input->post('title'),
			'content' => $this->input->post('content')
		);
		$this->tasks_model->add_task($data);

		$this->index();
	}

	function delete(){
		$id = $this->uri->segment(3);
		$this->tasks_model->delete_task($id);
		$this->index();
	}

	function update(){
		$data = array(
			'title' => $this->input->post('title'),
			'content' => $this->input->post('content')
		);
	}

	function is_logged_in(){
		$is_logged_in = $this->session->userdata('is_logged_in');
		if (!isset($is_logged_in) || $is_logged_in != true) {
			echo "You don't have permission";
			die();
		}
	}

	function logout(){
		$this->session->sess_destroy();
		redirect('/');
	}
*/


}

/* End of file blog.php */
/* Location: ./application/controllers/blog.php */



<div class="container">
	<div class="row">
		<div class="col-sm-12">
			<?php Kint::dump($task->responsible[0]); ?>
		</div>
		<div class="col-sm-12">
			<h3>You are currently editing - <small><?php echo $task->title; ?></small> </h3>
			<hr>
			<div class="row">
				<div class="col-sm-8 task_description">
					<div class="form-group">
						<label>Title</label>
						<input type="text" class="form-control" name="title" value="<?php echo $task->title; ?>" />
					</div>
					<div class="form-group">
						<label>Description</label>
						<textarea name="content"><?php echo $task->content; ?></textarea>
					</div>
				</div>
				<div class="col-sm-4" id="info">
					
					<div class="panel panel-default">
						<div class="panel-heading">Information <a href="#" class="editable pull-right"><i class="fa fa-pencil"></i></a></div>
						<div class="panel-body">

							<p><strong>Owner:</strong> <?php echo $task->owner; ?><br>
							<small><em>Posted On: <?php echo mdate('%M %d, %Y',strtotime($task->date_created)); ?></em></small></p>

							<div class="form-group">
								<div class="row">
									<div class="col-sm-3 middle">
										<label for="date" class="nowrap">Due Date:</label>
									</div>
									<div class="col-sm-9">
										<input type="date" name="date_due" class="form-control"  value="<?php echo $task->date_due; ?>" />
									</div>
								</div>
							</div>

							<div class="form-group">
								<div class="row">
									<div class="col-sm-3 middle">
										<label for="priority">Priority:</label>
									</div>
									<div class="col-sm-9">
										<select class="form-control" placeholder="-Select-" name="priority">
										  <option value="1" <?php $priority = (intval($task->priority) == 1) ? 'selected="selected"' : ""; echo $priority; ?> >Low</option>
										  <option value="2" <?php $priority = (intval($task->priority) == 2) ? 'selected="selected"' : ""; echo $priority; ?> >Normal</option>
										  <option value="3" <?php $priority = (intval($task->priority) == 3) ? 'selected="selected"' : ""; echo $priority; ?> >High</option>
										</select>
									</div>
								</div>
							</div>
							
							<div class="form-group">
								<div class="row">
									<div class="col-sm-3 middle">
										<label for="status">Status:</label>
									</div>
									<div class="col-sm-9">
										<select class="form-control" placeholder="-Select-" name="status">
										  <option value="1" <?php $status = (intval($task->status) == 1) ? 'selected="selected"' : ""; echo $status; ?> >Not Started</option>
										  <option value="2" <?php $status = (intval($task->status) == 2) ? 'selected="selected"' : ""; echo $status; ?> >In Progress</option>
										  <option value="3" <?php $status = (intval($task->status) == 3) ? 'selected="selected"' : ""; echo $status; ?> >Completed</option>
										</select>
									</div>
								</div>
							</div>

							
						</div>
					</div>


					<div class="panel panel-default">
						<div class="panel-heading">Assigned Roles<a href="#" class="editable pull-right"><i class="fa fa-pencil"></i></a></div>
						<div class="panel-body">

						<div class="form-group">
								<div class="row">
									<div class="col-sm-3 middle">
										<label for="responsible">Responsible:</label>
									</div>
									<div class="col-sm-9">
										<select multiple class="form-control" name="responsible">
										
										<?php // foreach ($task->responsible as $task_string): ?>
											<?php // Kint::dump(json_decode($task_string['id'])); ?>
											<?php 
												// $responsibleObject = json_decode($task_string);
												// Kint::dump($responsibleObject[0]->id);
											?>
										<?php // endforeach ?>

										<?php 

										foreach ($users as $user) {
											$id = intval($user->id, 10);
											echo<<<RESPONSIBLE
											<option name="responsible[]" value="$user->id"> $user->first_name $user->last_name</option>

RESPONSIBLE;
										};

									?>
										</select>
									</div>
								</div>
							</div>

							<!-- <p style="margin-bottom:0;"><strong>Responsible: </strong></p> -->
							<p style="margin-bottom: 0;"><strong>Responsible: </strong>
							<small><em>
							<?php
								foreach ($task->responsible as $users_array) {
									$users = json_decode($users_array);
									foreach ($users as $user) {
										echo '<span class="names">'.$user->name .'</span>';
									}
								};
							?>
							</em></small>
							</p>
							<p><strong>Accountable: </strong><small><em>
							<?php
								foreach ($task->accountable as $users_array) {
									$users = json_decode($users_array);
									foreach ($users as $user) {
										echo '<span class="names">'.$user->name.'</span>';
									}
								};
							?>
							</em></small>
							</p>
							<p style="margin-bottom: 0;"><strong>Consulted: </strong></p>
							<p><small><em>
							<?php
								foreach ($task->consulted as $users_array) {
									$users = json_decode($users_array);
									foreach ($users as $user) {
										echo '<span class="names">'.$user->name.'</span>';
									}
								};
							?>
							</em></small>
							</p>
							<p style="margin-bottom: 0;"><strong>Informed: </strong></p>
							<p><small><em>
							<?php
								foreach ($task->informed as $users_array) {
									$users = json_decode($users_array);
									foreach ($users as $user) {
										echo '<span class="names">'.$user->name.'</span>';
									}
								};
							?>
							</em></small>
							</p>
						</div>
					</div>
					
				</div>
			</div>
			
		</div>
	</div>
</div>